use std::collections::HashMap;

use model_graph_types::{
    database::{DataSource, DatabaseType},
    datasource::{
        DeleteCondition, DeleteOptions, InsertOptions, QueryCondition, UpdateCondition,
        UpdateOptions,
    },
    modeling::{Class, ClassPersistence, Value, ValueOperator},
};

pub fn genertate_query_one_sql(
    datasource: &DataSource,
    clazz: &Class,
    keys: &Vec<String>,
    mapping: ClassPersistence,
) -> anyhow::Result<String> {
    //
    //查询主键
    let key_names = &clazz.primary_key;
    let where_keys = key_names
        .split(",")
        .collect::<Vec<_>>()
        .iter()
        .map(|key_name| format!("{} = ? ", key_name))
        .collect::<Vec<String>>()
        .join(" and ");

    Ok(format!(
        "SELECT * FROM {} WHERE {}",
        mapping.table_name, where_keys
    ))
}
